package com.bilibili.controller;

import com.bilibili.entity.PicPage;
import com.bilibili.service.PicPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 专门用于处理漫画章节的Controller
 * @Author Sandy
 */
@RestController
@RequestMapping("pic_page")
public class PicPageController {

    @Autowired
    private PicPageService picPageService;

    /**
     * @param cartoonId 漫画id
     * @return 该漫画更新到多少集
     */
    @RequestMapping(value = "getCount", method = RequestMethod.GET, params = {"cartoonId"})
    public Integer getPageCountByCartoonId(@RequestParam("cartoonId") Integer cartoonId) {
        return picPageService.getPageCountByCartoonId(cartoonId);
    }

    /**
     *
     * @param cartoonId 漫画id
     * @return 属于该漫画的章节实体类,但不包括每个章节包含的细节
     */
    @RequestMapping(value = "getPage", method = RequestMethod.GET, params = {"cartoonId"})
    public List<PicPage> getPagesByCartoonId(@RequestParam("cartoonId") Integer cartoonId) {
        return picPageService.getPagesByCartoonId(cartoonId);
    }

}
